add server.shutdown() method to SocketServer 路 Issue #41934 路 python/cpython 路 GitHub

您所在的位置:网站首页 python socketserver shutdown add server.shutdown() method to SocketServer 路 Issue #41934 路 python/cpython 路 GitHub

add server.shutdown() method to SocketServer 路 Issue #41934 路 python/cpython 路 GitHub

#add server.shutdown() method to SocketServer 路 Issue #41934 路 python/cpython 路 GitHub| 来源: 网络整理| 查看: 265

It seems that .await_request() was only added a month ago to fix issue 742598, so it's no great hardship to refactor it again now. Timeouts never worked for .serve_forever() because the try/except in .handle_request() turned their exception into a plain return, which didn't stop .server_forever() from looping. Timeouts also seem to be unnecessary in a situation in which shutdown works. Shutdown can only be called from a separate thread, and when you have more threads you can also do periodic tasks in them.

So I've made that explicit: the .serve_forever/shutdown combination doesn't handle timeouts. [This has nothing to do with the fact that it takes three times as much code to handle them. Don't look at the excuse behind the curtain. ;)]

This patch needs some more documentation and a NEWS entry before it gets submitted, but I want to check that everyone would be happy with the concept.



【本文地址】


今日新闻


推荐新闻


CopyRight 2018-2019 办公设备维修网 版权所有 豫ICP备15022753号-3